package com.lanca;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@EnableDiscoveryClient  //只要引入discovery client依赖,会自动注入
@EnableHystrixDashboard //开启奈菲的熔断仪表盘监控
public class HystrixDashBoardApplication {

    public static void main(String[] args) {
        SpringApplication.run(HystrixDashBoardApplication.class, args);
    }

//    /**
//     * 入口类配置 你要监控那个服务，就把这个放在那个服务去
//     *
//     * @return ServletRegistrationBean
//     */
//    @Bean
//    public ServletRegistrationBean<HystrixMetricsStreamServlet> getServlet() {
//        HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
//        ServletRegistrationBean<HystrixMetricsStreamServlet> registrationBean = new ServletRegistrationBean<>(streamServlet);
//        registrationBean.setLoadOnStartup(1);
////        registrationBean.addUrlMappings("/hystrix.stream");
//        registrationBean.addUrlMappings("/actuator/hystrix.stream");
//        registrationBean.setName("HystrixMetricsStreamServlet");
//        return registrationBean;
//    }

    /**
     * Uncaught TypeError: e.indexOf is not a function
     * EventSource's response has a MIME type ("text/plain") that is not "text/event-stream". Aborting the connection.
     * http://localhost:8990/hystrix.stream 不要 https
     */
}
